<template>
	<view class="content">
		<view class="wid100 dis disAl disJuC" style="height: 100rpx;background-color: #37BCC3;">
			<input class="wid90 mar hei60 textCen bacFFF borRad40" v-model="suosou" @input="suosouInput" placeholder="搜索店员" />
		</view>
		<scroll-view style="height: calc(100vh - 100rpx);" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view style="height: 1rpx;"></view>
			<block v-for="(item,index) in list" :key="index">
				<view class="wid90 mar bacFFF borRad20 mar-top30 fowe600 poRel" 
					style="padding: 50rpx 0;" @click="tiaozhuan('/pages/salesclerk/particulars?id='+item.id)">
					<view class="dis disAl wid90 mar">
						<image v-if="item.avatar" :src="url+item.avatar" class="borRad50" style="width: 128rpx;height: 128rpx;"></image>
						<image v-if="!item.avatar" :src="url+'/addon/qianyu_petrol/wxapp/image/header.png'" 
							class="borRad50" style="width: 128rpx;height: 128rpx;"></image>
						<view class="mar-left30">
							<view class="foSi40">{{item.name}}</view>
							<view class="foSi30 mar-top20">{{item.mobile}}</view>
						</view>
					</view>
					<image v-if="item.identity == 0" src="../../static/dianzhang.png" 
						class="poAbs" style="width: 118rpx;height: 128rpx;top: 0;right: 0;"></image>
				</view>
			</block>
			<view style="height: 50rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				timer: null,
				suosou: '',
				last_page: 0,
				page: 1,
				list: []
			}
		},
		onLoad() {
			this.yuan_userinfo = uni.getStorageSync('yuan_userinfo')
			this.getList()
		},
		onShow() {},
		methods: {
			getList() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_clerk_list',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						gas_station_id: that.yuan_userinfo.gas_station_id,
						search: that.suosou,
						page: that.page,
						limit: 10,
						clerk_id: that.yuan_userinfo.id
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.last_page = result.data.last_page
							that.list = that.list.concat(result.data.data)
						}
					}
				})
			},
			suosouInput: function(event) {
				var that = this
				if (that.timer !== null) clearTimeout(that.timer)
				that.timer = setTimeout(() => {
					that.suosou = event.target.value
					console.log(that.money)
					that.list = []
					that.getList()
				}, 1000)
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background: #F8F9FD;
		height: 100vh;
	}
	.xia{
		height: 1rpx;
		background-color: #E5E5E5;
	}
</style>
